home *** CD-ROM | disk | FTP | other *** search
/ CompuServe CD 495W / Compuserve XTreme Edition 495W.iso / shopping / toyota / toyota.dir / 01110.ls < prev    next >
Encoding:
Text File  |  1995-08-09  |  3.5 KB  |  110 lines

  1. on initializeFields
  2.   put " " into field "zipHole"
  3.   set the textFont of field "zipHole" to "Helvetica"
  4.   set the textSize of field "zipHole" to 18
  5.   put EMPTY into field "zipHole"
  6.   put "Enter a five digit zip code." into field "displayResults"
  7. end
  8.  
  9. on checkKey
  10.   set x to charToNum(the key)
  11.   if ((x < 48) or (x > 57)) and (x <> 8) then
  12.     dontPassEvent()
  13.   end if
  14.   if (length(field "zipHole") = 5) and (x <> 8) then
  15.     dontPassEvent()
  16.   end if
  17. end
  18.  
  19. on checkFieldLength
  20.   if length(field "zipHole") = 5 then
  21.     go("sea")
  22.   end if
  23. end
  24.  
  25. on searchAndReport
  26.   global index, zip, foist
  27.   set foist to 1
  28.   put EMPTY into field "displayResults"
  29.   if length(field "zipHole") < 5 then
  30.     put "Please enter five digits and press return." into field "displayResults"
  31.     put EMPTY into field "zipHole"
  32.   else
  33.     put "Let me look up zip code" && field "zipHole" & "." & RETURN & "Back in a flash!" into field "displayResults"
  34.     set zip to field "zipHole"
  35.     set xx to char 1 to 2 of field "zipHole"
  36.     set flag to 0
  37.     set index to 1
  38.     repeat while line index of field xx <> EMPTY
  39.       if line index of field xx contains zip then
  40.         report(xx)
  41.         set flag to 1
  42.       end if
  43.       set index to index + 5
  44.     end repeat
  45.     set xy to string(value(xx) - 1)
  46.     if value(xy) < 0 then
  47.       set xy to "00"
  48.     end if
  49.     if length(xy) < 2 then
  50.       put "0" before xy
  51.     end if
  52.     set index to 1
  53.     repeat while line index of field xy <> EMPTY
  54.       if line index of field xy contains zip then
  55.         report(xy)
  56.         set flag to 1
  57.       end if
  58.       set index to index + 5
  59.     end repeat
  60.     set xz to string(value(xx) - 2)
  61.     if value(xz) < 0 then
  62.       set xz to "00"
  63.     end if
  64.     if length(xz) < 2 then
  65.       put "0" before xz
  66.     end if
  67.     set index to 1
  68.     repeat while line index of field xz <> EMPTY
  69.       if line index of field xz contains zip then
  70.         report(xz)
  71.         set flag to 1
  72.       end if
  73.       set index to index + 5
  74.     end repeat
  75.     if flag = 0 then
  76.       put "To locate a dealer near you:" & RETURN & "Call 1-800-GO-TOYOTA!" into field "displayResults"
  77.     else
  78.       put RETURN after field "displayResults"
  79.     end if
  80.     put EMPTY into field "zipHole"
  81.   end if
  82. end
  83.  
  84. on report zz
  85.   global index, zip, foist
  86.   if foist = 1 then
  87.     put "The Toyota Dealer(s) nearest to zip code" && zip && "is(are):" & RETURN into field "displayResults"
  88.   end if
  89.   put RETURN & line index + 1 of field zz & RETURN & line index + 2 of field zz & RETURN after field "displayResults"
  90.   put word 1 to 3 of line index + 3 of field zz after field "displayResults"
  91.   set x to charToNum(char 1 of word 3 of line index + 3 of field zz)
  92.   if (x < 48) or (x > 57) then
  93.     put " " & word 4 of line index + 3 of field zz after field "displayResults"
  94.   end if
  95.   set x to charToNum(char 1 of word 4 of line index + 3 of field zz)
  96.   if (x < 48) or (x > 57) then
  97.     put " " & word 5 of line index + 3 of field zz after field "displayResults"
  98.   end if
  99.   set x to charToNum(char 1 of word 5 of line index + 3 of field zz)
  100.   if (x < 48) or (x > 57) then
  101.     put " " & word 6 of line index + 3 of field zz after field "displayResults"
  102.   end if
  103.   set x to charToNum(char 1 of word 6 of line index + 3 of field zz)
  104.   if (x < 48) or (x > 57) then
  105.     put " " & word 7 of line index + 3 of field zz after field "displayResults"
  106.   end if
  107.   put RETURN & "(" & char 1 to 3 of line index + 4 of field zz & ") " & char 4 to 6 of line index + 4 of field zz & "-" & char 7 to 10 of line index + 4 of field zz & RETURN after field "displayResults"
  108.   set foist to 0
  109. end
  110.